package com.ncp.servlet.product;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.product.ManageBackstageProductBiz;
import com.ncp.model.biz.product.ManageFrontProductBiz;
import com.ncp.model.entity.product.ProductAllInfoBean;
import com.ncp.model.entity.product.ProductSortBean;

public class ManagerBasicLoadDelServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request,response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		boolean b1 =false,b2=false;
		String path1 = request.getServerName();
		String path2 = request.getRealPath(path1);
		int n=path2.lastIndexOf("\\");
		String S_realPath=path2.substring(0,n);
		String realPath =S_realPath+"\\"; 
		 int ProductID = Integer.parseInt(request.getParameter("ProductID"));
	
		    ManageBackstageProductBiz mbp = new ManageBackstageProductBiz();
		   
			
		    b2 = mbp.delImgsInTomcat(ProductID,realPath);
		    b1 = mbp.setProductBasicLoadDel(ProductID);
			 
		   
			if(b1==true){
				String pages = "ManagerShowBasicLoadServlet?type=del&PageNow=1";
				request.setAttribute("pages",pages );
				request.getRequestDispatcher("pages/admin/product/suc.jsp").forward(request,response);
				
			}else{
				
				request.getRequestDispatcher("pages/admin/product/err.jsp").forward(request,response);
			}
		
		
	
	}

}
